public class Customer {
    public static final String ERROR_OPTION = "Select a valid option!";
    public static final String SUCCESS_CHECKOUT_MESSAGE = "Thank you! Enjoy the book.";
    public static final String UNSUCCESSFUL_CHECKOUT_MESSAGE = "That book is not available.";
    public static final String RETURN_BOOK_SUCCESSFUL = "Thank you for returning the book.";
    public static final String RETURN_BOOK_UNSUCCESSFUL = "That is not a valid book to return.";
    private String name;
    private final int checkoutId;
    private Biblioteca biblioteca;
    private String email;
    private String phoneNum;

    public Customer(String name, int checkoutId) {
        this.name = name;
        this.checkoutId = checkoutId;
    }

    public void setLibrary(Biblioteca biblioteca) {
        this.biblioteca = biblioteca;
    }

    public String choose(String category) {
        boolean result = biblioteca.choose(category);
        if(!result){
            System.out.println(ERROR_OPTION);
            return ERROR_OPTION;
        }
        return "";
    }

    public String checkout(String name) {
        Resource book = biblioteca.checkoutResource("Book", name, checkoutId);
        if(book != null){
            System.out.println(SUCCESS_CHECKOUT_MESSAGE);
            return SUCCESS_CHECKOUT_MESSAGE;
        }
        System.out.println(UNSUCCESSFUL_CHECKOUT_MESSAGE);
        return UNSUCCESSFUL_CHECKOUT_MESSAGE;
    }

    public String returnBook(String bookName) {
        boolean result = biblioteca.returnBook(bookName, checkoutId);

        if(result){
            System.out.println(RETURN_BOOK_SUCCESSFUL);
            return RETURN_BOOK_SUCCESSFUL;
        }
        System.out.println(RETURN_BOOK_UNSUCCESSFUL);
        return RETURN_BOOK_UNSUCCESSFUL;
    }



    public void setEmail(String email) {
        this.email = email;
    }

    public String getEmail() {
        return email;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setPhoneNum(String phoneNum) {
        this.phoneNum = phoneNum;
    }

    public String getPhoneNum() {
        return phoneNum;
    }
}
